home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 February / GAME_2.ISO / utilities / Opera 5.01 / Opera501_final_nonjava.exe / OPERA.JAR / netscape / javascript / JSObject.class (.txt) < prev   
Encoding:
Java Class File  |  2000-12-07  |  2.4 KB  |  121 lines

  1. package netscape.javascript;
  2.  
  3. import java.applet.Applet;
  4. import opera.PluginContext;
  5.  
  6. public final class JSObject {
  7.    private int js_object;
  8.    private int doc_ptr;
  9.    private Object result;
  10.  
  11.    private JSObject(int var1, int var2) {
  12.       this.js_object = var1;
  13.       this.doc_ptr = var2;
  14.       this.ref();
  15.    }
  16.  
  17.    public Object call(String var1, Object[] var2) throws JSException {
  18.       try {
  19.          synchronized(this) {
  20.             JSObject var4 = (JSObject)this.getMember(var1);
  21.             if (var4 != null) {
  22.                if (this.startCall(var4, var2)) {
  23.                   this.wait();
  24.                   if (this.result instanceof JSException) {
  25.                      throw (JSException)this.result;
  26.                   }
  27.                } else {
  28.                   this.result = null;
  29.                }
  30.  
  31.                Object var5 = this.result;
  32.                return var5;
  33.             } else {
  34.                throw new JSException("Method " + var1 + " not found.");
  35.             }
  36.          }
  37.       } catch (InterruptedException var8) {
  38.          return null;
  39.       }
  40.    }
  41.  
  42.    private native boolean startCall(JSObject var1, Object[] var2);
  43.  
  44.    public Object eval(String var1) throws JSException {
  45.       try {
  46.          synchronized(this) {
  47.             if (this.startEval(var1)) {
  48.                this.wait();
  49.                if (this.result instanceof JSException) {
  50.                   throw (JSException)this.result;
  51.                }
  52.             } else {
  53.                this.result = null;
  54.             }
  55.  
  56.             Object var3 = this.result;
  57.             return var3;
  58.          }
  59.       } catch (InterruptedException var6) {
  60.          return null;
  61.       }
  62.    }
  63.  
  64.    private native boolean startEval(String var1);
  65.  
  66.    public static JSObject getWindow(Applet var0) throws JSException {
  67.       PluginContext var1 = (PluginContext)var0.getAppletContext();
  68.       if (var1 != null) {
  69.          int var2 = var1.getJSWindow();
  70.          if (var2 != 0) {
  71.             return new JSObject(var2, var1.getDocumentPtr());
  72.          }
  73.       }
  74.  
  75.       return null;
  76.    }
  77.  
  78.    public native Object getMember(String var1);
  79.  
  80.    public native void setMember(String var1, Object var2);
  81.  
  82.    public native void removeMember(String var1);
  83.  
  84.    public native Object getSlot(int var1);
  85.  
  86.    public native void setSlot(int var1, Object var2);
  87.  
  88.    public String toString() {
  89.       try {
  90.          Object var1 = this.eval("this.toString()");
  91.          return var1 != null && var1 instanceof String ? (String)var1 : null;
  92.       } catch (JSException var2) {
  93.          return null;
  94.       }
  95.    }
  96.  
  97.    protected void finalize() {
  98.       try {
  99.          this.unref();
  100.          super.finalize();
  101.       } catch (Throwable var2) {
  102.       }
  103.  
  104.    }
  105.  
  106.    private native void ref();
  107.  
  108.    private native void unref();
  109.  
  110.    private void setResult(Object var1) {
  111.       synchronized(this) {
  112.          this.result = var1;
  113.          this.notify();
  114.       }
  115.    }
  116.  
  117.    private void setExceptionResult() {
  118.       this.result = new JSException("JavaScript exception");
  119.    }
  120. }
  121.